﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microhard.Framework.MVCHelper;
using Microhard.Permission.Models;
using System.Web.Mvc;

namespace Microhard.WebUI.Models
{
    public static class DTOExtesion
    {
        public static TreeViewItem<Resouce> ToTreeViewItem(this Resouce res)
        {
            TreeViewItem<Resouce> rtn = new TreeViewItem<Resouce>();
            rtn.Text = res.Name;
            rtn.Value = res.ResourceID.ToString();
            if (res.SubResources != null)
            {
                rtn.Items = res.SubResources.Select(r => r.ToTreeViewItem()).ToList();
            }
            return rtn;
        }

    }
}